// 在types.ts中明确定义
type SpecName = string; // 规格名称
type SpecValueType = string; // 规格值
export interface ProductListParams {
  page: number;
  limit: number;
  name?: string;
  status?: number | string;
}

export interface CategoryItem {
  id: string;
  name: string;
  parentId: string;
}
export interface ProductListResponse {
  pagination: any;
  list: ProductItem[];
}
export interface ProductDetailSkus {
  
}
export interface ProductDetailSkusResponse {
  data: {
    skus: ProductDetailSkus[];
  };
}
export interface ProductDetailResponse {
  data: ProductInfo;
}

export interface ProductItem {
  id: string;
  name: string; // 商品名称
  code: string; // 商品编码
  thumbnail: string; // 缩略图
  images: string[]; // 图片链接
  videoUrl: string; // 视频链接
  description: string; // 描述
  sku: string; // SKU编码
  spec: string; // 规格
  price: string; // 售价
  costPrice: number; // 成本价
  stock: number; // 库存
  weight: number; // 重量
  status: string; // draft: 上架 published: 下架  archived: 删除
  category_id: string; // 分类ID
  categoryName: string; // 分类名称
  createTime: string;
  updateTime: string;
}

export interface ProductInfo extends  ProductItem{
  id: string;
  name: string;
  description: string;
  category: string;
  priceRange: [number, number];
  defaultImage: string;
  images: string[];
  slug: string;
  price: string;
  salesCount: number;
  category_id: string;
  specs: Array<{
    name: string;
    values: string[];
    images?: Record<string, string>;
    sizeChart?: Record<string, Record<string, string>>;
  }>;
  sku_name: string;
  skus: Array<{
    id: string;
    specs: Record<string, string>;
    price: number;
    originalPrice?: number;
    stock: number;
    image?: string;
    barcode?: string;
    weight?: string;
  }>;
  promotions?: Array<{
    type: string;
    title: string;
    desc: string;
  }>;
  services?: Array<{
    name: string;
    icon: string;
  }>;
  rating?: {
    average: number;
    count: number;
    distribution: number[];
  };
}

export interface Sku {
  id: string;
  specs: Record<string, string>;
  price: number;
  stock: number;
  image?: string; // 可选属性
  originalPrice?: number;
  barcode?: string;
  weight?: string;
}

export interface Spec {
  name: SpecName;
  values: SpecValueType[];
  images?: Record<SpecValueType, string>;
}
export interface CreateProductParams {
  name: string;
  price: number;
  stock: number;
  status: string;
  category_id: string;
}

export interface SpecListResponse {
  pagination: any;
  list: SpecItem[];
}
export interface SpecValue {
  id: string | number;
  name: string;
  value?: string;     // 可选，兼容旧代码
  image?: string;     // 规格值对应图片
  // 其他可能存在的属性...
}

// 完整规格类型定义
export interface SpecType {
  id: string | number;
  name: string;       // 规格名称 (如 "颜色")
  values: SpecValue[]; // 规格值列表
  
  // 可选业务字段
  category_id?: string;
  description?: string;
  deleted_at?: string | null;
}
// 定义规格类型
export interface SpecItem {
  id: string;
  name: string;
  category_id: string; // 分类ID
  values: SpecValue[];
  description: string;
  deleted_at?: string;
}

export interface CreateSpecTypesParams {
  name: string;
  values: string[];
  category_id: string;
  description: string;
}


// SKU 规格项
export interface SkuSpec {
  spec_type_id: string | number;
  spec_name: string;
  spec_value_id: string | number;
  value: string;
  image?: string;     // 可选覆盖图片
}

// SKU 完整定义
export interface SkuItem {
  id: string;
  sku_name: string;   // 组合名称 (如 "红色/XL")
  specs: SkuSpec[];   // 规格明细
  price: number;
  stock: number;
  image: string | null; // 主图
  barcode?: string;    // 条形码
  weight?: number;     // 重量
  cost_price?: number; // 成本价
}